package com.internetCafes.spms.web.certificate.model.certificate.req;

import com.internetCafes.spms.web.certificate.common.cont.CertTransactionConst;
import com.internetCafes.spms.web.certificate.entity.CertiTransactionInfo;
import com.internetCafes.spms.web.certificate.entity.CertificateInfo;
import com.internetCafes.spms.web.certificate.model.certificate.podo.CertTransactionInfoDo;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

/**
 * 证书流转请求参数
 *
 * @author HHKJ-SERVER-ZJ 2022/6/14 16:07
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class CertTransactionInfoReq extends CertTransactionInfoDo {

    /**
     * 证书状态
     */
    private Integer status;

    /**
     * 缴费凭证列表
     */
    private String payPic;

    /**
     * 证书信息
     */
    private CertificateInfo certInfoPo;

    /**
     * 证书信息列表
     */
    private List<CertificateInfo> certInfoPoList;

    /**
     * 还回/收回 对应的流转记录
     */
    private CertiTransactionInfo returnFromTransactionInfoPo;

    /**
     * 证书id列表
     */
    private List<Long> certIdList;

    /**
     * 从借出信息中复制还回信息
     * @param borrowOutInfo 借出信息
     */
    public void copyBorrowOutInfoToReturn(CertiTransactionInfo borrowOutInfo) {
        this.setStatusTag(CertTransactionConst.StatusTag.COMPLETION.getId());
        this.setCertificateId(borrowOutInfo.getCertificateId());
        this.setType(CertTransactionConst.Type.BORROW_OUT_RETURN.getId());
        this.setFromDeptName(borrowOutInfo.getToDeptName());
        this.setFromDeptId(borrowOutInfo.getToDeptId());
        this.setFromUserName(borrowOutInfo.getToUserName());
        this.setFromUserId(borrowOutInfo.getToUserId());
        this.setFromUserMobile(borrowOutInfo.getToUserMobile());
        this.setFromDeptName(borrowOutInfo.getToDeptName());
        this.setFromUserName(borrowOutInfo.getToUserName());
        this.setFromUserMobile(borrowOutInfo.getToUserMobile());
        this.setToDeptName(borrowOutInfo.getFromDeptName());
        this.setToUserName(borrowOutInfo.getFromUserName());
        this.setToDeptId(borrowOutInfo.getFromDeptId());
        this.setToUserId(borrowOutInfo.getFromUserId());
        this.setToUserMobile(borrowOutInfo.getFromUserMobile());
    }

    /**
     * 收回时，从挂出的数据中 复制需要的数据
     * @param affiliationOutInfo 挂出记录数据
     */
    public void copyAffiliationOutInfoToReturn(CertiTransactionInfo affiliationOutInfo) {
        this.setType(CertTransactionConst.Type.AFFILIATION_OUT_RETURN.getId());
        this.setCertificateId(affiliationOutInfo.getCertificateId());
        this.setFromDeptName(affiliationOutInfo.getToDeptName());
        this.setFromDeptId(affiliationOutInfo.getToDeptId());
        this.setFromUserName(affiliationOutInfo.getToUserName());
        this.setFromUserId(affiliationOutInfo.getToUserId());
        this.setFromUserMobile(affiliationOutInfo.getToUserMobile());
        this.setFromDeptName(affiliationOutInfo.getToDeptName());
        this.setFromUserName(affiliationOutInfo.getToUserName());
        this.setFromUserMobile(affiliationOutInfo.getToUserMobile());
        this.setToDeptName(affiliationOutInfo.getFromDeptName());
        this.setToUserName(affiliationOutInfo.getFromUserName());
        this.setToDeptId(affiliationOutInfo.getFromDeptId());
        this.setToUserId(affiliationOutInfo.getFromUserId());
        this.setToUserMobile(affiliationOutInfo.getFromUserMobile());
        this.setStatusTag(CertTransactionConst.StatusTag.COMPLETION.getId());
        this.setReturnFromId(affiliationOutInfo.getId());
    }
}
